<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    p {
      margin: 0;;
      width: 300px;
      height: 300px;
      border:1px solid red;
      display: none;
    }

    .p-active{
      display: block;
    }
    .button-active{
      background: red;
    }
  </style>
</head>
<body>
  <button class="button-active" data-index="0">1</button>
  <button data-index="1">2</button>
  <button data-index="2">3</button>
  <div>
    <p class="p-active">111111111</p>
    <p>22222222</p>
    <p>33333333</p>
  </div>

  <script>
    var btns = document.querySelectorAll('button')
    var listP = document.querySelectorAll('p')

    for(var i = 0; i < btns.length; i++) {
      btns[i].onclick = function() {
        for(var i = 0; i < btns.length; i++) {  // 将所有按钮清楚高粱
          btns[i].className = ''
        }
        this.className = 'button-active'

        for(var j = 0; j < listP.length; j++) {  // 控制p标签全部清除高亮
          listP[j].className = ''
        }
        var index = this.getAttribute('data-index')
        listP[index].className = 'p-active'
      }
    }
  </script>
</body>
</html>